package util;

import javazoom.jl.player.Player;

import java.io.BufferedInputStream;
import java.io.InputStream;

/***
 * Author: Mr.Zhao, Time: 2018/5/3/15:10
 * Description: 用来播放音频文件
 */
public class Mp3Player {
    /* 第三方类 */
    private Player player;

    public Mp3Player() {
    }

    /**
     * @author 赵永远
     */
    public void play(String fileName) {

        InputStream inputStream = Mp3Player.class.getResourceAsStream("/resources/sound/" + fileName);

        try {
            BufferedInputStream buffer = new BufferedInputStream(inputStream);
            player = new Player(buffer);
            player.play();
        } catch (Exception e) {
            System.out.println(e);
        }
    }

    public Player getPlayer() {
        return this.player;
    }
}
